package com.piper.email.controller;

import com.piper.email.entity.Email;
import com.piper.email.loadblanch.ILoadBalance;
import com.piper.email.service.IEmailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/email")
@Api("邮件推送接口")
public class EmailController {

    @Autowired
    private ILoadBalance strategy;

    @PostMapping
    @ApiOperation("发送邮件")
    public boolean healthCheck(@RequestBody Email email) {
        IEmailService service = strategy.select();
        return service.sendEmail(email);
    }
}
